package com.gee.spring.boot.oauth2.auth.config.web;

import com.gee.spring.boot.oauth2.common.util.http.ResponseUtil;
import com.gee.spring.boot.oauth2.common.util.result.ResultCode;
import com.gee.spring.boot.oauth2.common.util.result.ResultUtil;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * desc:
 * 登出成功后的处理
 * @author gee
 * @date 2020/04/01 22:43
 */
@Component(value = "logoutSuccessHandler")
public class GeeLogoutSuccessHandler implements LogoutSuccessHandler {
    @Override
    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException {
        ResponseUtil.writeJson(response, ResultUtil.success(ResultCode.LOGOUT_SUCCESS));
    }
}
